# Copyright (C) Kumo inc. and its affiliates.
# Author: Jeff.li lijippy@163.com
# All rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https:#www.gnu.org/licenses/>.
#
# Build the test and build container for presto_cpp
ARG image=quay.io/centos/centos:stream9
FROM $image

COPY scripts/setup-helper-functions.sh /
COPY scripts/setup-centos9.sh /

# Building libpollux.so requires melon and gflags to be built shared as well for now
ENV  POLLUX_BUILD_SHARED=ON
# The removal of the build dir has to happen in the same layer as the build
# to minimize the image size. gh & jq are required for CI
RUN mkdir build && ( cd build && bash /setup-centos9.sh ) && rm -rf build && \
        dnf install -y -q 'dnf-command(config-manager)' && \
        dnf config-manager --add-repo 'https://cli.github.com/packages/rpm/gh-cli.repo' && \
        dnf install -y -q gh jq && \
        dnf clean all

ENV CC=/opt/rh/gcc-toolset-12/root/bin/gcc \
    CXX=/opt/rh/gcc-toolset-12/root/bin/g++

ENTRYPOINT ["/bin/bash", "-c", "source /opt/rh/gcc-toolset-12/enable && exec \"$@\"", "--"]
CMD ["/bin/bash"]
